﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace Workflow
{
    public partial class ReturnReason : System.Web.UI.Page
    {
        int workParentId;
        int workChildId;
        private WorkflowManager objWorkflowManager = new WorkflowManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            workParentId = Convert.ToInt32(Request.QueryString["WorkParentId"]);
            workChildId = Convert.ToInt32(Request.QueryString["WorkChildId"]);
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            try
            {
                btnReturn.Enabled = false;
                objWorkflowManager.ReturnWorkflow(workChildId, workParentId, txtReturnReason.Text.Trim().ToString());
                objWorkflowManager.InsertWorkflowLog(workParentId, workChildId,Session["DisplayName"].ToString(),"Return", txtReturnReason.Text.Trim().ToString());
                //string msg = "退回成功！是否要关闭本页";
                string msgForm = string.Format("<script>alert('退回成功！');window.opener.location.reload();window.close();</script>");
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "", msgForm);
            }
            catch (Exception ex)
            {
                string msg = string.Format("<script>alert('{0}');</script>", ex.Message.ToString());
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", msg);
            }
            
        }
    }
}